import request from '@/utils/request'

// 分页查询数据
export function pagePlanManagement(qurey) {
  return request({
    url: '/user/enterprisePlanManagement/paging',
    method: 'get',
    params: qurey
  })
}
// 统计计划
export function countPlanManagement(qurey) {
  return request({
    url: '/user/enterprisePlanManagement/countPlanManagement',
    method: 'get',
    params: qurey
  })
}
// 保存计划
export function savePlan(qurey) {
  return request({
    url: '/user/enterprisePlanManagement/save',
    method: 'post',
    data: qurey
  })
}
// 更新企业计划状态
export function updatePlanManagementStatus(qurey) {
  return request({
    url: '/user/enterprisePlanManagement/updatePlanManagementStatus',
    method: 'get',
    params: qurey
  })
}
// 复制企业计划
export function copyPlanManagement(qurey) {
  return request({
    url: '/user/enterprisePlanManagement/copyPlanManagement',
    method: 'get',
    params: qurey
  })
}
// 根据Id企业计划
export function getPlanManagementById(qurey) {
  return request({
    url: '/user/enterprisePlanManagement/getPlanManagementById',
    method: 'get',
    params: qurey
  })
}

// =============================== 计划和合伙人关系  ===============================

// 获取计划的合伙人列表
export function getPlanPartnerListById(qurey) {
  return request({
    url: '/user/userEnterprisePlanPartnerRelation/paging',
    method: 'get',
    params: qurey
  })
}

// 删除计划和合伙人关系
export function deletePlanPartnerRelation(userEnterprisePlanPartnerRelationId) {
  return request({
    url: '/user/userEnterprisePlanPartnerRelation/delete',
    method: 'post',
    params: {
      userEnterprisePlanPartnerRelationId
    }
  })
}

// 保存计划和合伙人关系,要传企业id
// 支持批量或单个：单个就：partnerId,多个就：parnterIds
export function savePlanPartnerRelation(data) {
  return request({
    url: '/user/userEnterprisePlanPartnerRelation/save',
    method: 'post',
    data: data
  })
}

// 根据计划id，删除所有计划和合伙人的关系
export function deleteByPlanId(planId) {
  return request({
    url: '/user/userEnterprisePlanPartnerRelation/deleteByPlanId',
    method: 'post',
    params: {
      planId
    }
  })
}

// =============================== 计划和合伙人关系  ===============================

// =============================== 计划和商品关系  ===============================

// 计划和商品的关系分页查询数据
export function pagePlanGoodsRelationList(qurey) {
  return request({
    url: '/user/enterprisePlanGoodsRelation/paging',
    method: 'get',
    params: qurey
  })
}

// 保存计划和商品的关系
export function savePlanGoodsRelation(data) {
  return request({
    url: '/user/enterprisePlanGoodsRelation/save',
    method: 'post',
    data: data
  })
}

// 批量保存计划和商品的关系，商品id集合
export function batchSavePlanGoodsRelationByGoodsIds(data) {
  return request({
    url: '/user/enterprisePlanGoodsRelation/saveBatchByGoodsIds',
    method: 'post',
    data: data
  })
}

// 根据关系id,批量删除
export function deleteBatchPlanGoodsRelation(relationIds) {
  return request({
    url: '/user/enterprisePlanGoodsRelation/deleteBatch',
    method: 'post',
    data: {
      relationIds: relationIds
    }
  })
}

// 根据计划id，更新所有商品佣金比例
export function updatePlanGoodsCommissionRateByPlanId(planId, commissionRate) {
  return request({
    url: '/user/enterprisePlanGoodsRelation/updatePlanGoodsCommissionRateByPlanId',
    method: 'post',
    data: {
      planId: planId,
      commissionRate: commissionRate
    }
  })
}
// =============================== 计划和商品关系  ===============================
